package com.vic.delayedqueue.consumer;

import com.rabbitmq.client.Channel;
import com.vic.delayedqueue.config.DelayedQueue3Config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;

import java.io.IOException;
import java.util.Date;

/**
 * 延时队列的消费者
 */
@Slf4j
//@Component
public class DelayedQueue3Consumer {

    @RabbitListener(queues = DelayedQueue3Config.DELAYED_QUEUE)
    public void receiveD(Message message, Channel channel) throws IOException {
        String msg = new String(message.getBody());
        log.info("当前时间: {}，收到延时队列信息: {}", new Date(), msg);
    }

}
